<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const str = '<year src="http://wwwbaidu">caijiao</year>'
        const req = /<year src=(.*)>(.*)<\/year>/
        const res = req.exec(str)
        console.log(res)
        console.log(res[0])
        //命名分组，(.*)=>(?<name>.*),(正则表达式)=>(?<name>表达式),
        const req1 = /<year src=(?<src>.*)>(?<other>.*)<\/year>/
        const res1 = req1.exec(str)
        console.log(res1)
        console.log(res1.groups.src)  
    </script>
</body>
</html>